<?php

/**
* Generator namespace
* 
*/
abstract class Generator 
{
    
    /**
    * Session namespace
    * 
    */
    const SESSION_NAMESPACE = 'CUEGENERATOR';
    
    /**
    * Start session. Return generated session key.
    * 
    * @return string
    */
    static public function startSession() 
    {
        $key = md5(uniqid(rand()));
        $_SESSION[self::SESSION_NAMESPACE][$key] = array();
        return $key;
    }
    
    /**
    * Return whether session with given key is valid
    * 
    * @param string $key
    * @return bool
    */
    static public function isSessionValid($key) 
    {
        return @array_key_exists($key, $_SESSION[self::SESSION_NAMESPACE]);
    }
    
}